﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 经典推箱子
{
    /// <summary>
    /// 选择关卡窗体
    /// </summary>
    public partial class SelectForm : Form
    {
        /// <summary>
        /// 选择的关卡序号
        /// </summary>
        public static int no;

        public SelectForm(int no)
        {
            InitializeComponent();
            this.Init();
            SelectForm.no = no;
        }

        private void Init()
        {
            DirectoryInfo directory = new DirectoryInfo($"Level");
            this.Text = $"选择关卡【{1}~{directory.GetFiles().Count()}】";
        }

        /// <summary>
        /// 确定选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Ok_Click(object sender, EventArgs e)
        {
            try
            {
                SelectForm.no = int.Parse(this.textBox_No.Text.Trim());
                this.Close();
            }
            catch(Exception exception)
            {
                MessageBox.Show(exception.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
